package com.zhs.gccs.dao.converter;

import android.database.Cursor;

import com.google.gson.Gson;
import com.zhs.gccs.model.LocationBean;

import org.xutils.db.converter.ColumnConverter;
import org.xutils.db.sqlite.ColumnDbType;

public class LocationBeanConverter implements ColumnConverter<LocationBean> {
    @Override
    public LocationBean getFieldValue(Cursor cursor, int index) {
        if(cursor.isNull(index)){
            return null;
        }else {
            String s =cursor.getString(index);
            Gson gson = new Gson();
            LocationBean img = gson.fromJson(s,LocationBean.class);
            return img;
        }
    }

    @Override
    public Object fieldValue2DbValue(LocationBean img) {
        Gson gson = new Gson();
        String s = gson.toJson(img);
        return s;
    }

    @Override
    public ColumnDbType getColumnDbType() {
        return ColumnDbType.TEXT;
    }
}
